<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('新增回款异常')"/>
    <th:block th:include="include :: select2-css"/>
    <th:block th:include="include :: datetimepicker-css"/>
</head>
<style>
    input::-webkit-outer-spin-button,
    input::-webkit-inner-spin-button {
        -webkit-appearance: none;
    }

    input[type="number"] {
        -moz-appearance: textfield;
    }
</style>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-backPay-add">
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">工程公司：</label>
            <div class="col-sm-8">
                <select name="compName" class="form-control">
                    <option value="">请选择</option>
                    <option th:each="comp : ${comp}" th:text="${comp.compName}"
                            th:value="${comp.compName}" th:title="${comp.compId}"></option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">项目名称：</label>
            <div class="col-sm-8">
                <select name="proName" class="form-control">
                    <option value="">请选择</option>
                    <option th:each="pro : ${pro}" th:text="${pro.proName}"
                            th:value="${pro.proName}"></option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">年份：</label>
            <div class="col-sm-8">
                <select name="years" class="form-control">
                    <option value="">请选择</option>
                    <option th:each="years : ${years}" th:text="${years.years}+'年'"
                            th:value="${years.years}"></option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">月份：</label>
            <div class="col-sm-8">
                <select name="months" class="form-control">
                    <option value="">请选择</option>
                    <option th:each="months : ${months}" th:text="${months.monthInYear}+'月'"
                            th:value="${months.monthInYear}"></option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">计划回款数：</label>
            <div class="col-sm-8">
                <input class="form-control" type="number" name="planBack" onchange="changeBackPay()" placeholder="请输入计划回款数">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">实际回款数：</label>
            <div class="col-sm-8">
                <input class="form-control" type="number" name="realityBack" onchange="changeBackPay()" placeholder="请输入实际回款数">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">差额：</label>
            <div class="col-sm-8">
                <input class="form-control" type="number" name="difference" readonly>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">完成率：(%)</label>
            <div class="col-sm-8">
                <input class="form-control" type="number" name="completionRate" readonly>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">备注：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" name="remarks" placeholder="请输入备注">
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: select2-js"/>
<th:block th:include="include :: datetimepicker-js"/>
<script>
    var prefix = ctx + "backPay";

    function changeBackPay(){
        var planBack=$("input[name='planBack']").val();
        var realityBack=$("input[name='realityBack']").val();
        $("input[name='difference']").val(planBack-realityBack);
        $("input[name='completionRate']").val(Number(realityBack / planBack*100).toFixed(2));
    }

    function submitHandler() {
        if ($.validate.form()) {
            var data = $("#form-backPay-add").serializeArray();
            $.operate.save(prefix + "/add", data);
        }
    }

</script>
</body>
</html>